// pages/jishuguanli/jishu_item/jishu_item.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    jishu:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(app.globalData.jishu)
    this.setData({
      jishu:app.globalData.jishu
    })
    var jishu = this.data.jishu
    // for(var i = 0 ; i< jishu.wenjian.length ; i++){
    //   jishu.flieName[i] = jishu.flieName[i]+"."+ jishu.wenjian[i].split('.')[ jishu.wenjian[i].split('.').length - 1 ]
    // }
    this.setData({
      jishu:jishu
    })
  },
  /**
   * 浏览文件
   * @param {*} e 
   */
  yulan(e){
    var that = this
    console.log(e.currentTarget.dataset.id)
   wx.navigateTo({
     url: '../../s/s?url='+that.data.jishu.wenjian[e.currentTarget.dataset.id]
   })
  },
   /**
   * 查看图片
   * @param {*} e 
   */
  ViewImage(e) {
    wx.previewImage({
      urls: this.data.jishu.zhaopian,
      current: e.currentTarget.dataset.url
    });
  },
  /**
   * 复制
   * @param {*} e 
   */
  fuzhi(){
    var that = this
    var k = ""
    for(var i = 0 ; i<that.data.jishu.wenjian.length ; i++){
       k = k + that.data.jishu.flieName[i] + ":" +that.data.jishu.wenjian[i] +"\n"
    }
    wx.setClipboardData({
      data: "视频路径 :" + that.data.jishu.shiping.join(',') + "\n图片路径 :"+that.data.jishu.zhaopian.join(',')+"\n文件路径 :" + k,
      success() {
        wx.showToast({
          title: '复制成功',
          icon: 'success',
          duration: 1000
        })
      }
    })
  },
  /**
   * 编辑
   * @param {*} e 
   */
  bianji(){
    app.globalData.bian = this.data.jishu
    wx.navigateTo({
      url: '../jishubian/jishubian',
    })
  }
})